package csdn;


interface IFly {
    void fly();
}

class Bird implements IFly{
    private String name;

    public Bird(String name) {
        this.name = name;
    }

    @Override
    public void fly() {
        System.out.println(name+"用翅膀飞！");
    }
}

class Plane implements IFly{
    private String type;

    public Plane(String type) {
        this.type = type;
    }

    @Override
    public void fly() {
        System.out.println(type+"用机翼飞！");
    }
}


//测试
public class Test {
    public static void main(String[] args) {
        IFly fly1=new Bird("啄木鸟");
        IFly fly2=new Plane("战斗机");
        fly1.fly();
        fly2.fly();
        //判断对象fly1是否实现了IFly接口
        if(fly1 instanceof IFly) {
            System.out.println("Yes");
        }
        //判断对象fly1是否是Bird的实例
        if(fly1 instanceof Bird) {
            System.out.println("Yes");
        }

    }
}

